package com.zer0.tga.math;


public class Coordinate{

	public Coordinate()
	{
		setCoordinate(0,0);
	}
	
	
	public Coordinate(double x, double y)
	{
		setCoordinate(x,y);
	}
	
	
	public double x;
	public double y;
	
	
	public Coordinate getNorthCoordinate()
	{
		return new Coordinate(this.x,this.y-1);
	}
	
	public Coordinate getSouthCoordinate()
	{
		return new Coordinate(this.x,this.y+1);
	}
	
	public Coordinate getWestCoordinate()
	{
		return new Coordinate(this.x-1,this.y);
	}
	
	public Coordinate getEastCoordinate()
	{
		return new Coordinate(this.x+1,this.y);
	}
	
	public Coordinate getCoordinate(Direction d)
	{
		if(d == Direction.NORTH)
			return getNorthCoordinate();
		else if(d == Direction.SOUTH)
			return getSouthCoordinate();
		else if(d == Direction.EAST)
			return getEastCoordinate();
		else if(d == Direction.WEST)
			return getWestCoordinate();
		else
			return null;
	}
	
	public void setCoordinate(double x, double y)
	{
		this.x = x;
		this.y = y;
	}
	
	public int getX()
	{
		return (int) Math.round(x);
	}

	public int getY()
	{
		return (int) Math.round(y);
	}
}
